package isquirrel;

import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentLinkedQueue;

import isquirrel.beans.UserInterest;

public class QueuePool {
	
	@SuppressWarnings("unchecked")
	private static HashMap<String, ConcurrentLinkedQueue> _pool;
	
	private QueuePool(){
	}
	
	
	@SuppressWarnings("unchecked")
	public synchronized static ConcurrentLinkedQueue getQueue(String key){
		
		if (_pool == null){
			_pool = new HashMap<String, ConcurrentLinkedQueue>();
		}
		
		if (_pool.containsKey(key)){
			return _pool.get(key);
		}
		else{
			return null;
		}
	}
	
	@SuppressWarnings("unchecked")
	public synchronized static <T> void addQueue(String key, Class<T> klass){
	
		if (_pool == null){
			_pool = new HashMap<String, ConcurrentLinkedQueue>();
		}
		
		_pool.put(key, new ConcurrentLinkedQueue<T>());
		
	}

	

}
